<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        //倒计时效果
        //思路：将来的时间戳-现在的时间戳，再转换为时分秒
        function countDown(time) {
            let nowTime = +new Date();//返回的是当前时间总的毫秒数
            let inputTime = +new Date(time);//返回的是用户输入的时间总的毫秒数
            let times = (inputTime - nowTime) / 1000;  //除以1000得到秒数
            let d = parseInt(times / 60 / 60 / 24); //天
            d = d < 10 ? '0' + d : d;   //怎么不执行？
            let h = parseInt(times / 60 / 60 % 24); //时
            h = h < 10 ? '0' + h : h;
            let m = parseInt(times / 60 % 60); //分
            m = m < 10 ? '0' + m : m;
            let s = parseInt(times % 60); //当前的秒
            s = s < 10 ? '0' + s : s;
            return d + '天' + h + '时' + m + '分' + s + '秒';
        }
        console.log(countDown('2023-6-23 11:00:00'));
        var date = new Date();
        console.log(date);
    </script>
</head>

<body>

</body>

</html>